$("#back").on("click",function(){
    window.location.href = "userlist";
});

$("#addUserBtn").on("click",function () {
    //收集参数
    var devName = $.trim($("#devName").val());
    var devCode = $.trim($("#devCode").val());
    var devPassword = $.trim($("#devPassword").val());
    var reDevPassword = $.trim($("#reDevPassword").val());
    var devEmail = $.trim($("#devEmail").val());
    var devInfo = $.trim($("#devInfo").val());
    //表单验证
    if (devName==""){
        alert("用户名不能为空！")
        return;
    }
    if (devCode==""){
        alert("用户账号不能为空！")
        return;
    }
    if (devPassword==""){
        alert("密码不能为空！")
        return;
    }
    if (reDevPassword==""){
        alert("请重复输入密码！")
        return;
    }
    if (devEmail==""){
        alert("用户邮箱不能为空！")
        return;
    }
    if (reDevPassword==devPassword){
        //发送异步请求
        $.ajax({
            url:'saveDevUser',
            data:{
                devCode:devCode,
                devName:devName,
                devPassword:devPassword,
                devEmail:devEmail,
                devInfo:devInfo
            },
            type:'post',
            dataType:'json',
            success:function (data) {
                if (data.code=="1"){
                    alert("添加用户成功！")
                    window.location.href='userlist';
                }else {
                    alert(data.message)
                    return;
                }
            }
        })
    }else{
        alert("两次输入的密码不相同！")
        return;
    }

})